package com.itany.mall.dao.mapper;

import java.sql.ResultSet;

import com.itany.mall.entity.User;
import com.itany.mall.jdbc.template.callback.RowMapper;

public class UserRowMapper implements RowMapper<User> {

	public String selectSql() {
		StringBuffer sql = new StringBuffer();
		sql.append(" select ");
		sql.append("     u.id, u.name, u.password, ");
		sql.append("     u.phone, u.email, u.role ");
		sql.append(" from t_user u ");
		return sql.toString();
	}

	@Override
	public User mapRow(ResultSet res) throws Exception {
		User u = new User();
		u.setId(res.getLong("id"));
		u.setName(res.getString("name"));
		u.setPassword(res.getString("password"));
		u.setPhone(res.getString("phone"));
		u.setEmail(res.getString("email"));
		u.setRole(res.getInt("role"));
		return u;
	}

}
